package lc20240605;

import java.util.ArrayList;
import java.util.List;

public class Graph {
    //顶点表数组
    List<VexNode> vexNodes = new ArrayList<>();
    int vNum;
    int edgeNum;

    void addEdge(VexNode node, VexNode node1) {
        if (!node.neigh.contains(node1)) {
            node.neigh.add(node1);
        }
        edgeNum++;
    }
    void addVNode(VexNode node){
        vNum++;
    }
}

//顶点表
class VexNode {
    int val;
    //指向第一个邻接点
    List<VexNode> neigh;

    public VexNode(int val) {
        this.val = val;
        this.neigh = new ArrayList<>();
    }

    @Override
    public String toString() {
        return "VexNode{" +
                "val=" + val +
                ", neigh=" + neigh +
                '}';
    }
}

